<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<title>index.html</title>
	#style
	<!-- 监听键盘事件 -->
	<script type="text/javascript" src="$!basePath/framework/js/core/plugin/zframe.keyboard.js"></script> 
	<!-- <script type="text/javascript" src="$!basePath/framework/js/core/zframe-datagrid-scrollview.js"></script> -->
</head>
 <body class="easyui-layout">
 <script type="text/javascript">
	$(function(){
	     initDataGrid();
	     initWindows();
	     initToolbar();
	     //设置键盘监听控件参数
		KeyBoard.GridName = "dgLogList";
		KeyBoard.Ctrl = true;
		KeyBoard.Shift = true;
		KeyBoard.Init();
	});
	function initDataGrid(){
		$('#dgLogList').datagrid({
			autoRowHeight:false,
			collapsible:true,
			url:'$!basePath/admin/log/logList',
			sortName:'time',
			sortOrder:'desc',
			remoteSort: true,
			border:false,
			fit:true,
			idField:'id',
			singleSelect:true,
			nowrap:false,
			//view:scrollview,
			frozenColumns:[[
	                {field:'ck',checkbox:true},
	                {title:'序号',field:'id',width:40,sortable:true}
				]],
				columns:[[
					{field:'time',title:'Timestamp',width:150,sortable:true,formatter: function(value,row,index){
							return ">&nbsp;"+value.substring(0,19);
						}
					},
					{field:'type',title:'Level',width:60,formatter:function(value,row,index){
						if(row.type == 1){
							return "INFO";
						}else if(row.type == 2){
							return "<span style='color:orange'>DEBUG</span>";
						}else if(row.type == 3){
							return "<span style='color:red'>ERROR</span>";
						}
					}},
					{field:'manipulateName',title:'操作事项',width:120,sortable:true,formatter:function(value,row,index){
							return highShowSearch($("#dgLogList"),"manipulateName",value);
						}},
					{field:'className',title:'Logger',width:120,sortable:true,formatter:function(value,row,index){
						return highShowSearch($("#dgLogList"),"className",value);
						}},
					{field:'content',title:'操作结果',width:300,sortable:true,formatter:function(value,row,index){
							return highShowSearch($("#dgLogList"),"content",value);
						}},
					{field:'userName',title:'操作人',width:100,sortable:true,formatter:function(value,row,index){
							return highShowSearch($("#dgLogList"),"userName",value);
						}},
					{field:'ip',title:'来源IP',sortable:true,width:100}
				]],
				pagination:true,
				rownumbers:true,
				toolbar:'#dgLogList-toolbar',
				onHeaderContextMenu: function(e,field){
					e.preventDefault();
					//创建表头右键菜单
					DataGridUtil.createHeadContextMenu("dgLogList");
					//显示表头右键菜单
					DataGridUtil.showHeadContextMenu("dgLogList",e);
				},
				onRowContextMenu:function(e,rowindex,rowData){
					rowContentMenuShowHandler(e,rowindex,rowData,"dgLogList","dgLogList_rowContextMenu");
				},
				onLoadSuccess : function(){
					DataGridUtil.initDataGridColumn("dgLogList");
				},
				rowStyler:function(index,row){
					/* if(row.type == 3){
						return 'background-color:red;color:#fff;';
					}else if(row.type == 2){
						return 'background-color:yellow;';
					} */
				}
				
		});
	}
	function initWindows(){
		
	}
	function rowContentMenuClickHandler(item){
		ContentMenuClickHandler("dgLogList",item);
	}
	function initToolbar(){
		$("#btnRemove").attr("deleteUrl","$!basePath/admin/log/doDelete");
		$("#btnRemove").click(function(){
			DataGridUtil.Delete("$!basePath/admin/log/doDelete","dgLogList");
		});
		$("#btnExportExcel").click(function(){
			DataGridUtil.exportExcel($("#dgLogList"),"Log");
		});
	}
	function doSearch(v,n){
		doDataGridSearch("dgLogList",n,v);
	}
	//按下Ctrl键之后的回调函数
	function CtrlKeyEvent(eventType){
		if(eventType == "down"){
			$("#dgLogList").datagrid("options").singleSelect = false;
		}else if(eventType=="up"){
			$("#dgLogList").datagrid("options").singleSelect = true;
		}
	};
 </script>
    <div data-options="region:'center',border:true">
		<table id="dgLogList"></table>
    </div>
    <!-- 工具条 -->
    <div id="dgLogList-toolbar" style="padding:2px 0;" class="datagrid-toolbar">
		<table cellpadding="0" cellspacing="0" style="width:100%">
			<tr>
				<td style="padding-left:2px">
					<a id="btnRemove" href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-log-delete',plain:true" style="float: left;">删除</a>
					<div class="datagrid-btn-separator"></div>
					<a id="btnExportExcel" href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-export-excel',plain:true" style="float: left;">导出Excel</a>
					<select class="easyui-combobox" data-options="width:100,onChange:function(newVal,oldVal){
						if(newVal != -1){
							$('#dgLogList').datagrid('load',{name:'type',value:newVal});
						}else{
							$('#dgLogList').datagrid('load',{name:'',value:''});
						}
					}">
						<option value="-1">选择Level</option>
						<option value="1">INFO</option>
						<option value="2">DEBUG</option>
						<option value="3">ERROR</option>
					</select>
				</td>
				<td style="text-align:right;padding-right:2px">
					<input id="ss" style="width:240px;" class="easyui-searchbox" data-options="searcher:doSearch,prompt:'请输入查询内容',menu:'#ss_mm'"></input>
					<div id="ss_mm" style="width:80px;">
						<div data-options="name:'manipulateName'">操作事项</div>
						<div data-options="name:'userName'">操作人</div>
						<div data-options="name:'className'">操作类</div>
						<div data-options="name:'content'">操作结果</div>
						<div data-options="name:'iP'">登录IP</div>
					</div>
				</td>
			</tr>
		</table>
	</div>
	<!-- 右键菜单 -->
	<div id="dgLogList_rowContextMenu" data-options="onClick:rowContentMenuClickHandler" class="easyui-menu" style="width:120px;">
		<div name="select" data-options="iconCls:'icon-ok'">选中</div>
		<div name="remove" data-options="iconCls:'icon-log-delete'" with="btnRemove">删除此日志</div>
		
	</div>
  </body>
</html>